﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IHISCETeim.DAL;
using IHISCETeim.Model;
using IHISCETeim.Library;
using System.Data;
namespace IHISCETeim.BLL
{
    /// <summary>
    /// 冲帐记录
    /// </summary>
    public class FTradeBalanceController
    {
        /// <summary>
        /// 添加新的冲帐记录
        /// 1,需处理相应的应收记录金额及状态
        /// 2.需处理收款列表余额及状态
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static bool Add(List<FTradeBalanceInfo> objs,decimal ShengYuJinE)
        {
            return FTradeBalanceDAL.Add(objs, ShengYuJinE);
        }
        /// <summary>
        /// 调帐操作
        /// </summary>
        /// <param name="obj">添加新的　收款记录</param>
        /// <param name="FbalanceIds">原冲帐记录列表</param>
        /// <returns></returns>
        public static bool AddAdjusting(FTradeCatheringInfo obj, List<int> FbalanceIds)
        {
            return FTradeBalanceDAL.AddAdjusting(obj, FbalanceIds);
        }

        /// <summary>
        /// 调帐操作2,用于 做调帐 时用
        /// </summary>
        /// <param name="obj">添加新的　收款记录</param>
        /// <param name="FbalanceIds">原冲帐记录列表</param>
        /// <param name="FbalanceIds">调帐金额列表</param>
        /// <returns></returns>
        public static bool AddAdjusting2(FTradeCatheringInfo obj, List<int> FbalanceIds, List<decimal> AdjustingMoneys, List<decimal> oldAdjustingMoneys)
        {
            return FTradeBalanceDAL.AddAdjusting2(obj, FbalanceIds, AdjustingMoneys, oldAdjustingMoneys);
        }

        public static bool AddAdjusting2(Dictionary<int, FTradeCatheringInfo> FTradeCatheringList,Dictionary<int, List<FTradeAdjustingTemp>> FTradeAdList)
        {
            return FTradeBalanceDAL.AddAdjusting2(FTradeCatheringList, FTradeAdList);
        }

        /// <summary>
        /// 获取冲帐记录或可调帐的记录
        /// </summary>
        /// <param name="WhereSql"></param>
        /// <returns></returns>
        public static DataTable GetAddAdjustingList(string WhereSql)
        {
            return FTradeBalanceDAL.GetAddAdjustingList(WhereSql);
        }

        public static DataTable GetAddAdjustingList(string WhereSql, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            return FTradeBalanceDAL.GetAddAdjustingList(WhereSql, PageIndex,PageSize,Sort,ref TotalCount);
        }
        /// <summary>
        /// 根据充帐ID，获取其下所有的冲帐记录
        /// </summary>
        /// <param name="FCatheringId"></param>
        /// <returns></returns>
        public static DataTable GetFTradeBalanceByFCatheringId(int FCatheringId)
        {
            return FTradeBalanceDAL.GetFTradeBalanceByFCatheringId(FCatheringId);
        }
        /// <summary>
        /// 根据机号，获取其下所有的冲帐记录
        /// </summary>
        /// <param name="FCatheringId"></param>
        /// <returns></returns>
        public static DataTable GetFTradeBalanceByJiHao(string JiHao)
        {
            return FTradeBalanceDAL.GetFTradeBalanceByJiHao(JiHao);
        }
        ///// <summary>
        ///// 退机
        ///// </summary>
        ///// <param name="CanBalance">退机款是否用于冲帐</param>
        ///// <param name="objCatOld">生成的负收款值</param>
        ///// <param name="objCatNew">新的实际退款收款值</param>
        ///// <param name="FbalanceIds"></param>
        ///// <param name="IsHuanJi">是否是换机</param>
        ///// <returns>
        ///// 返回新的实际退款　收款项的ID
        ///// =0表示失败
        ///// </returns>
        //public static int AddTuiJi(int FTradeID, bool CanBalance, FTradeCatheringInfo objCatOld, FTradeCatheringInfo objCatNew, List<int> FbalanceIds, int IsHuanJi)
        //{
        //    return FTradeBalanceDAL.AddTuiJi(FTradeID, CanBalance, objCatOld, objCatNew, FbalanceIds, IsHuanJi);
        //}
    }
}
